//
//  PingTeTableViewCell.m
//  兼职页面
//
//  Created by kuiyuan liang on 2021/5/26.
//

#import "PingTeTableViewCell.h"
#import "CommonUtil.h"

@interface PingTeTableViewCell()

@property (strong, nonatomic) UIView * whiteView;
@property (strong, nonatomic) UILabel * numberLabel;
@property (strong, nonatomic) UILabel * resultLabel1;
@property (strong, nonatomic) UILabel * resultLabel2;
@property (strong, nonatomic) UILabel * resultLabel;

@property (strong, nonatomic) UILabel * suodingLabel;
@property (strong, nonatomic) UILabel * timeLabel;

@property (strong, nonatomic) UIView * lineView;
@property (strong, nonatomic) UIView * lineView2;

@property (strong, nonatomic) UIButton * subcriBtn;
@property (strong, nonatomic) UIButton * countBtn;

@end

@implementation PingTeTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.whiteView];
        [self.whiteView addSubview:self.numberLabel];
        [self.whiteView addSubview:self.resultLabel1];
        [self.whiteView addSubview:self.resultLabel2];
        [self.whiteView addSubview:self.resultLabel];
        
        [self.whiteView addSubview:self.suodingLabel];
        [self.whiteView addSubview:self.timeLabel];
        
        [self.whiteView addSubview:self.subcriBtn];
        [self.whiteView addSubview:self.countBtn];
        
        [self.whiteView addSubview:self.lineView];
        [self.whiteView addSubview:self.lineView2];
    }
    return self;
}


-(void)setPrizeModel:(DrawPrizeModel *)prizeModel{
    _prizeModel = prizeModel;
    _numberLabel.text = @"第035期";
    _resultLabel1.text = @"开: -? -";
    _resultLabel2.text = @"-对? -";
    _resultLabel.text = @"-牛-";
    _suodingLabel.text = @"锁定";
    _timeLabel.text = @"2021-04-30 01:19";
    
    if (prizeModel.showBtn) {
        _whiteView.height = AD(130);
    }else{
        _whiteView.height = AD(90);
    }
}

- (void)subcriBtnClick:(UIButton *)sender{
    NSLog(@"订阅");
}
- (void)countBtnClick:(UIButton *)sender{
    NSLog(@"统计");
}


-(UIView *)whiteView{
    if (!_whiteView) {
        _whiteView = [[UIView alloc] initWithFrame:CGRectMake(0, AD(5), SCREEN_WIDTH, AD(130))];
        _whiteView.backgroundColor = [UIColor whiteColor];
        _whiteView.layer.cornerRadius = AD(5);
        _whiteView.clipsToBounds = YES;
    }
    return _whiteView;
}

-(UILabel *)numberLabel{
    if (!_numberLabel) {
        _numberLabel = [[UILabel alloc] initWithFrame:CGRectMake(AD(20), AD(10), AD(80), AD(30))];
        _numberLabel.font = [UIFont boldSystemFontOfSize:AD(15)];
    }
    return _numberLabel;
}

-(UILabel *)resultLabel1{
    if (!_resultLabel1) {
        _resultLabel1 = [[UILabel alloc] initWithFrame:CGRectMake(AD(250), AD(10), AD(60), AD(30))];
        _resultLabel1.font = [UIFont systemFontOfSize:AD(14)];
    }
    return _resultLabel1;
}
-(UILabel *)resultLabel2{
    if (!_resultLabel2) {
        _resultLabel2 = [[UILabel alloc] initWithFrame:CGRectMake(_resultLabel1.right, AD(10), AD(60), AD(30))];
        _resultLabel2.font = [UIFont systemFontOfSize:AD(14)];
        _resultLabel2.textColor = RGB(128.0, 194.0, 52.0);
    }
    return _resultLabel2;
}

-(UILabel *)resultLabel{
    if (!_resultLabel) {
        _resultLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, AD(35), SCREEN_WIDTH, AD(30))];
        _resultLabel.font = [UIFont boldSystemFontOfSize:AD(15)];
        _resultLabel.textAlignment = NSTextAlignmentCenter;
    }
    return _resultLabel;
}

-(UILabel *)suodingLabel{
    if (!_suodingLabel) {
        _suodingLabel = [[UILabel alloc] initWithFrame:CGRectMake(AD(20), AD(60), AD(35), AD(15))];
        _suodingLabel.font = [UIFont systemFontOfSize:AD(12)];
        _suodingLabel.textColor = [UIColor whiteColor];
        _suodingLabel.layer.cornerRadius = AD(3);
        _suodingLabel.clipsToBounds = YES;
        _suodingLabel.textAlignment = NSTextAlignmentCenter;
        _suodingLabel.backgroundColor = RGB(39.0, 133.0, 217.0);
    }
    return _suodingLabel;
}

-(UILabel *)timeLabel{
    if (!_timeLabel) {
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-AD(150), AD(60), AD(130), AD(20))];
        _timeLabel.font = [UIFont systemFontOfSize:AD(12)];
        _timeLabel.textColor = [UIColor lightGrayColor];
        _timeLabel.textAlignment = NSTextAlignmentRight;
    }
    return _timeLabel;
}

-(UIView *)lineView{
    if (!_lineView) {
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(0, self.subcriBtn.top, SCREEN_WIDTH, AD(1))];
        _lineView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    }
    return _lineView;
}

-(UIView *)lineView2{
    if (!_lineView2) {
        _lineView2 = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, _lineView.bottom, AD(1), AD(40))];
        _lineView2.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
    }
    return _lineView2;
}

-(UIButton *)subcriBtn{
    if (!_subcriBtn) {
        _subcriBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_subcriBtn addTarget:self action:@selector(subcriBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_subcriBtn setTitle:@"订阅" forState:UIControlStateNormal];
        [_subcriBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _subcriBtn.titleLabel.font = [UIFont systemFontOfSize:AD(13)];
        [_subcriBtn setImage:[UIImage imageNamed:@"icon_lingdang"] forState:UIControlStateNormal];
        _subcriBtn.frame = CGRectMake(0, AD(90), SCREEN_WIDTH/2, AD(40));
    }
    return _subcriBtn;
}

-(UIButton *)countBtn{
    if (!_countBtn) {
        _countBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_countBtn addTarget:self action:@selector(countBtnClick:) forControlEvents:UIControlEventTouchUpInside];
        [_countBtn setTitle:@"统计" forState:UIControlStateNormal];
        [_countBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        _countBtn.titleLabel.font = [UIFont systemFontOfSize:AD(13)];
        [_countBtn setImage:[UIImage imageNamed:@"icon_count"] forState:UIControlStateNormal];
        _countBtn.frame = CGRectMake(_subcriBtn.right, self.lineView.top, SCREEN_WIDTH/2, AD(40));
    }
    return _countBtn;
}


@end
